﻿<?php 

@set_time_limit(0); 
if(!$_POST['submit'])exit(); 
@set_time_limit(0); 
$c1 = count($b1 = explode('.',$_SERVER['SERVER_NAME'])); 

require_once('mima.php'); 
if($_POST['auth']!=$Password)exit('--ok-- "Please write code"'); 
$sell_url = $_POST['sell_url']; 
$sell_folder= $_POST['sell_folder']; 
$sell_url2 = $_POST['sell_url2']; 
$sell_url3 = $_POST['sell_url3']; 
$com_url = $_POST['com_url']; 
$com_folder = $_POST['com_folder']; 
$buy_url = $_POST['buy_url']; 
$buy_folder = $_POST['buy_folder']; 
$im_url = $_POST['im_url']; 
$im_folder = $_POST['im_folder']; 
function size_image($imgfile) 
{ 
$info = getimagesize($imgfile); 
if(!$info)$info = getimagesize($imgfile); 
if(!$info)$info = getimagesize($imgfile); 
return $info; 
} 
function create_image($imgfile,$info) 
{ 
$im = null; 
switch ($info[2]){ 
case 1: $im=imagecreatefromgif($imgfile);break; 
case 2: $im=imagecreatefromjpeg($imgfile);break; 
case 3: $im=imagecreatefrompng($imgfile);break; 
default: echo '网速或图片格式原因停止下载,任务完成后，请只用图片配置再次发布直到全部图片处理完成！。'.$imgfile."\n\r"; 
} 
return $im; 
} 
require_once('mima.php'); 
function min_image($oldim,$info,$ww,$hh) 
{ 
$w = $info[0]; 
$h = $info[1]; 
$newim = imagecreatetruecolor($ww,$hh); 
$baise = imagecolorallocate($newim,255,255,255); 
imagefill($newim,0,0,$baise); 
if($w<$ww &&$h<$hh){ 
$ow = ($ww-$w)/2; 
$oh = ($hh-$h)/2; 
imagecopyresized($newim,$oldim,$ow,$oh,0,0,$w,$h,$w,$h); 
}else{ 
if($w/$ww >$h/$hh){ 
$w1 = $w/($w/$ww); 
$h1 = $h/($w/$ww); 
$oh = ($hh-$h1)/2; 
imagecopyresized($newim,$oldim,0,$oh,0,0,$w1,$h1,$w,$h); 
}elseif ($w/$ww == $h/$hh){ 
imagecopyresized($newim,$oldim,0,0,0,0,$ww,$hh,$w,$h); 
}elseif($w/$ww <$h/$hh) { 
$h1 = $h/($h/$hh); 
$w1 = $w/($h/$hh); 
$ow = ($ww-$w1)/2; 
imagecopyresized($newim,$oldim,$ow,0,0,0,$w1,$h1,$w,$h); 
} 
} 
return $newim; 
} 
function edit_url($url) 
{ 
$newfile = explode('/',$url); 
$newfile = $newfile[count($newfile)-1]; 
$newfile = explode('.',$newfile); 
$newfile = $newfile['0']; 
return $newfile; 
} 
switch ($_GET['t']){ 
case '1': 
if($sell_url){ 
$mark_image_info = size_image($mark_url); 
$sell_image_info = size_image($sell_url); 
$mark_image = create_image($mark_url,$mark_image_info); 
$sell_image = create_image($sell_url,$sell_image_info); 
$image = copy_image($sell_image,$mark_image,$sell_image_info,$mark_image_info,$sello); 
$newfile = edit_url($sell_url); 
if(!is_dir($sell_folder))mkdir($sell_folder,0777,TRUE); 
imagejpeg($image,"$sell_folder/$newfile.jpg"); 
if(file_exists("$sell_folder/$newfile.jpg")) 
{ 
$newim = min_image($image,$sell_image_info,140,140); 
imagejpeg($newim,"$sell_folder/".$newfile.'.jpg.thumb.jpg'); 
$newim = min_image($image,$sell_image_info,240,180); 
imagejpeg($newim,"$sell_folder/".$newfile.'.jpg.middle.jpg'); 
} 
if(imageistruecolor($mark_image))imagedestroy($mark_image); 
if(imageistruecolor($sell_image))imagedestroy($sell_image); 
if($image)unset($image); 
if(    file_exists("$sell_folder/$newfile.jpg")  
&&file_exists("$sell_folder/$newfile.jpg.thumb.jpg")  
&&file_exists("$sell_folder/$newfile.jpg.middle.jpg")) 
{ 
echo "<center>供应图片处理成功chenggong<br>\n\r</center>"; 
}else{ 
echo "<center>供应图片处理失败shibai<br>\n\r</center>"; 
} 
}else{echo "<center>为空的供应图片处理成功wutu<br>\n\r</center>";} 
if ($sellimg = '1'){ 
if($sell_url2){ 
$mark_image_info = size_image($mark_url); 
$sell_image_info = size_image($sell_url2); 
$mark_image = create_image($mark_url,$mark_image_info); 
$sell_image = create_image($sell_url2,$sell_image_info); 
$image = copy_image($sell_image,$mark_image,$sell_image_info,$mark_image_info,$sello); 
$newfile = edit_url($sell_url2); 
if(!is_dir($sell_folder))mkdir($sell_folder,0777,TRUE); 
imagejpeg($image,"$sell_folder/$newfile.jpg"); 
if(file_exists("$sell_folder/$newfile.jpg")) 
{ 
$newim = min_image($image,$sell_image_info,140,140); 
imagejpeg($newim,"$sell_folder/".$newfile.'.jpg.thumb.jpg'); 
$newim = min_image($image,$sell_image_info,240,180); 
imagejpeg($newim,"$sell_folder/".$newfile.'.jpg.middle.jpg'); 
} 
if(imageistruecolor($mark_image))imagedestroy($mark_image); 
if(imageistruecolor($sell_image))imagedestroy($sell_image); 
if($image)unset($image); 
if(    file_exists("$sell_folder/$newfile.jpg")  
&&file_exists("$sell_folder/$newfile.jpg.thumb.jpg")  
&&file_exists("$sell_folder/$newfile.jpg.middle.jpg")) 
{ 
echo "<center>供应图片处理成功chenggong<br>\n\r</center>"; 
}else{ 
echo "<center>供应图片处理失败shibai<br>\n\r</center>"; 
} 
}else{echo "<center>为空的供应图片处理成功wutu<br>\n\r</center>";} 
if($sell_url3){ 
$mark_image_info = size_image($mark_url); 
$sell_image_info = size_image($sell_url3); 
$mark_image = create_image($mark_url,$mark_image_info); 
$sell_image = create_image($sell_url3,$sell_image_info); 
$image = copy_image($sell_image,$mark_image,$sell_image_info,$mark_image_info,$sello); 
$newfile = edit_url($sell_url3); 
if(!is_dir($sell_folder))mkdir($sell_folder,0777,TRUE); 
imagejpeg($image,"$sell_folder/$newfile.jpg"); 
if(file_exists("$sell_folder/$newfile.jpg")) 
{ 
$newim = min_image($image,$sell_image_info,140,140); 
imagejpeg($newim,"$sell_folder/".$newfile.'.jpg.thumb.jpg'); 
$newim = min_image($image,$sell_image_info,240,180); 
imagejpeg($newim,"$sell_folder/".$newfile.'.jpg.middle.jpg'); 
} 
if(imageistruecolor($mark_image))imagedestroy($mark_image); 
if(imageistruecolor($sell_image))imagedestroy($sell_image); 
if($image)unset($image); 
if(    file_exists("$sell_folder/$newfile.jpg")  
&&file_exists("$sell_folder/$newfile.jpg.thumb.jpg")  
&&file_exists("$sell_folder/$newfile.jpg.middle.jpg")) 
{ 
echo "<center>供应图片处理成功chenggong<br>\n\r</center>"; 
}else{ 
echo "<center>供应图片处理失败shibai<br>\n\r</center>"; 
} 
}else{echo "<center>为空的供应图片处理成功wutu<br>\n\r</center>";} 
} 
if($com_url){ 
$com_image_info = size_image($com_url); 
$com_image = create_image($com_url,$com_image_info); 
$newfile = explode('/',$com_url); 
$newfile = $newfile[count($newfile)-1]; 
if(!is_dir($com_folder))mkdir($com_folder,0777,TRUE); 
imagejpeg($com_image,"$com_folder/$newfile"); 
if(imageistruecolor($com_image))imagedestroy($com_image); 
if(file_exists("$com_folder/$newfile")) 
{ 
echo "<center>公司图片处理成功chenggong<br>\n\r</center>"; 
}else{ 
echo "<center>公司图片处理失败shibai<br>\n\r</center>"; 
} 
}else{echo "<center>为空的公司图片处理成功wutu<br>\n\r</center>";} 
if($buy_url){ 
$mark_image_info = size_image($mark_url); 
$buy_image_info = size_image($buy_url); 
$mark_image = create_image($mark_url,$mark_image_info); 
$buy_image = create_image($buy_url,$buy_image_info); 
$image = copy_image($buy_image,$mark_image,$buy_image_info,$mark_image_info,$buyo); 
$newfile = edit_url($buy_url); 
if(!is_dir($buy_folder))mkdir($buy_folder,0777,TRUE); 
imagejpeg($image,"$buy_folder/$newfile.jpg"); 
if(file_exists("$buy_folder/$newfile.jpg")) 
{ 
$newim = min_image($image,$buy_image_info,140,140); 
imagejpeg($newim,"$buy_folder/".$newfile.'.jpg.thumb.jpg'); 
$newim = min_image($image,$buy_image_info,240,180); 
imagejpeg($newim,"$buy_folder/".$newfile.'.jpg.middle.jpg'); 
} 
if(imageistruecolor($mark_image))imagedestroy($mark_image); 
if(imageistruecolor($buy_image))imagedestroy($buy_image); 
if($image)unset($image); 
if(    file_exists("$buy_folder/$newfile.jpg")  
&&file_exists("$buy_folder/$newfile.jpg.thumb.jpg")  
&&file_exists("$buy_folder/$newfile.jpg.middle.jpg")) 
{ 
echo "<center>求购图片处理成功chenggong<br>\n\r</center>"; 
}else{ 
echo "<center>求购图片处理失败shibai<br>\n\r</center>"; 
} 
}else{echo "<center>为空的求购图片处理成功wutu<br>\n\r</center>";} 
break; 
case '2': 
if($im_url){ 
$im_image_info = size_image($im_url); 
$im_image = create_image($im_url,$im_image_info); 
$newfile = edit_url($im_url); 
if(!is_dir($im_folder))mkdir($im_folder,0777,TRUE); 
if ($moduleid == '21'){$kuan = 120;$gao == 90;} 
if ($moduleid == '22'){$kuan = 120;$gao == 90;} 
if ($moduleid == '13'){$kuan = 180;$gao == 60;} 
if ($moduleid == '7'){$kuan = 100;$gao == 100;} 
$image = min_image($image,$im_image_info,$kuan,$gao); 
imagejpeg($image,"$im_folder/$newfile.jpg"); 
if($im_image)unset($im_image); 
if(file_exists("$im_folder/$newfile.jpg")) 
{ 
echo "<center>图片处理成功chenggong<br>\n\r</center>"; 
}else{ 
echo "<center>图片处理失败shibai<br>\n\r</center>"; 
} 
}else{echo "<center>为空的图片处理成功wutu<br>\n\r</center>";} 
break; 
default: 
echo '你乱改什么呀，你看出错了吧'; 
} 

?>